<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.40/vue.global.js"></script>
</head>
<body>
    <div id="app">
        <home></home>
        <suspense>
            <asd></asd>
            <template #fallback>加载中。。。。</template>
        </suspense>
    </div>
    <template id="child">
        <div>
            加载完成
        </div>
    </template>
</body>
</html>
<script>
    // 由 defineAsyncComponent 使组件异步加载
    //在组件加载过程中 或出现空白现象
    //使用 suspense 标签包裹
    //用template标签写上内容 并写上自带标签 fallback
    const com = {
        template:'#child'
    }
    const {createApp,defineAsyncComponent} = Vue
    const asd = defineAsyncComponent(() => {
        return new Promise((resolve,reject) => {
            setTimeout(() =>{
                resolve(com)
            },3000)
        })
    })
    const app = createApp({
        components:{
            home:com,
            asd
        }
    })
    app.mount('#app')
</script>